$(function(){
        /**
         *获取url中指定字符变量的值
         */
        function getQueryString(name){  
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");  
            var r =location.search.substr(1).match(reg);  
            if (r != null){
                return unescape(r[2]);
            }else{
                return null;
            }      
        }
    var productId = (getQueryString("productId")!=null)?getQueryString("productId"):"";
        var url=SYS_GLOBAL_CONFIG.shaUrl,
        async="true",
        type="post";
    var data;
    console.log(url);
    data=JSON.stringify({"code":"getServiceDetail","version":"1.0","data":{"productId":productId}});
    console.log(data);               
    getData(url,data,call_func_succ,call_func_err,async,type);        
    
    /**
     *获取页面数据
     */
    function getData(url,requestData,call_func_succ,call_func_err,async,type){
            $.ajax({
                url:url,

                type:type,

                datatype:"json",

                contentType:"application/json",

                data:requestData,
                
                async:async,

                success:function(data){
                    call_func_succ(data);
                },
                error:function(msg){
                    call_func_err(msg);
                }   
        
            });        
        }
    /**
     *获取数据之后的回调函数
     */
   function call_func_succ(data){
       console.log(data);
        if(data.data){
           var dataServiceInfo=data.data.serviceInfo;
           $("title").html(dataServiceInfo.productName);
           $(".head-pic").attr("src",dataServiceInfo.userImgPath)
           $(".span-name").html(dataServiceInfo.userName);
           console.log(dataServiceInfo.userAuthStatus);
           if(dataServiceInfo.userAuthStatus==1){//认证标志
                $(".image-tag").attr("src","./images/personService.png");
           }else{
                $(".image-tag").get(0).style.display="none";
           }

           $(".hot-span1").html(dataServiceInfo.viewCount);
           $(".hot-span2").html(dataServiceInfo.serviceCollectCount);
           $(".p1").html(dataServiceInfo.productName);
            var str =dataServiceInfo.address;   
            if( str.split(" ").length>0){
                strs = str.split(" ");   
                $(".p2").html(strs[2]+"/"+strs[3]);
            }
           $(".p3").html(dataServiceInfo.parentServiceName +"&nbsp; . &nbsp;"+ dataServiceInfo.saleprice+"/"+dataServiceInfo.unit);
           $(".p4").html(dataServiceInfo.remark);
            
           $(".foot-span .message").attr("href","sms:"+dataServiceInfo.phoneNO);
           $(".foot-span .tell").attr("href","tel:"+dataServiceInfo.phoneNO);
            var len=dataServiceInfo.serviceImgs.length;
            var imgsData="";
            var lastIndex=0;
            var datafullpath="";
            if(len>0){
                for(var i=0;i<len;i++){
                    datafullpath=dataServiceInfo.serviceImgs[i].FULLPATH;
                    pathLen=datafullpath.length;
                    lastIndex=datafullpath.lastIndexOf(".");
                    str1=datafullpath.substr(0,lastIndex);
                    str2=datafullpath.substr(lastIndex,pathLen);
                    fullpath=str1+"_max"+str2;
                    imgsData+='<div class="pic-show-l"><img class="person-img" src="'+fullpath +'" alt=""></div>';
                }
                $(".pic-show").html(imgsData);
                //dataServiceInfo.serviceImgs[i].imageTittle图片标题
            }else{
                
            }
        }else{
            console.log("获取数据为空");
        }     
       
//       $(".p2").html(data.data.serviceInfo.productName);
   }
    
    function call_func_err(msg){
        console.log(msg);
        console.log("获取数据失败");
    }

});
